package com.block.datapush.service.apipush.utils;

import cn.hutool.core.util.StrUtil;
import com.block.common.enums.BaseTypeInfoEnum;
import org.apache.commons.lang3.StringUtils;

/**
 * 如意花 APIB回调
 */
public class RuYiHuaApiBUtil {

    //性别
    public static Integer getGender(Integer gender) {
       if (gender == 1){
           return 1;
       }
        return 2;
    }

    //公积金
    public static Integer getFund(String fund) {
        if (StrUtil.equals(fund, BaseTypeInfoEnum.Gjj.gjj001.getValue())) {
            return 0;
        }
        return 1;
    }

    //社保
    public static Integer getShebao(String shebao) {
        if (StrUtil.equals(shebao, BaseTypeInfoEnum.Shebao.sb001.getValue())) {
            return 0;
        }
        return 1;
    }

    //房产
    public static Integer getHouse(String house) {
        if (StrUtil.equals(house, BaseTypeInfoEnum.House.hu001.getValue())) {
            return 0;
        }
        return 1;
    }

    //车产
    public static Integer getCar(String car) {
        if (StrUtil.equals(car, BaseTypeInfoEnum.Car.car001.getValue())) {
            return 0;
        }
        return 1;
    }

    //保险
    public static Integer getBaoxian(String baoxian) {
        if (StrUtil.equals(baoxian, BaseTypeInfoEnum.Baoxian.bx001.getValue())) {
            return 0;
        }
        return 1;
    }

    //芝麻
    public static Integer getZhima(String zhima) {
        if (StrUtil.equals(zhima, BaseTypeInfoEnum.Zhima.zm001.getValue())){
            return 0;
        }else if (StrUtil.equals(zhima, BaseTypeInfoEnum.Zhima.zm002.getValue())) {
            return 1;
        } else if (StrUtil.equals(zhima, BaseTypeInfoEnum.Zhima.zm003.getValue())) {
            return 2;
        } else if (StrUtil.equals(zhima, BaseTypeInfoEnum.Zhima.zm004.getValue())) {
            return 3;
        }
        return 4;
    }

    //职业身份
    public static Integer getJob(String jbo) {
        if (StrUtil.equals(jbo, BaseTypeInfoEnum.Gongzuo.gz001.getValue())) {
            return 1;
        } else if (StrUtil.equals(jbo, BaseTypeInfoEnum.Gongzuo.gz002.getValue())) {
            return 3;
        } else if (StrUtil.equals(jbo, BaseTypeInfoEnum.Gongzuo.gz004.getValue())) {
            return 2;
        }
        return 5;
    }

    //IP
    public static String getIp(String ip) {
        if (StringUtils.isNotEmpty(ip)){
            return ip;
        }
        return "127.0.0.1";
    }

    //贷款金额
    public static Integer getLoanAmount(String loanAmount) {
        if (StrUtil.equals(loanAmount, BaseTypeInfoEnum.LoanAmount.la001.getValue())) {
            return 10000;
        } else if (StrUtil.equals(loanAmount, BaseTypeInfoEnum.LoanAmount.la002.getValue())) {
            return 30000;
        } else if (StrUtil.equals(loanAmount, BaseTypeInfoEnum.LoanAmount.la003.getValue())) {
            return 50000;
        }else if (StrUtil.equals(loanAmount, BaseTypeInfoEnum.LoanAmount.la004.getValue())) {
            return 100000;
        }
        return 200000;
    }

    //贷款时间
    public static Integer getLoanTerm(String loanTime) {
        if (StrUtil.equals(loanTime, BaseTypeInfoEnum.LoanTime.lt001.getValue())) {
            return 1;
        } else if (StrUtil.equals(loanTime, BaseTypeInfoEnum.LoanTime.lt002.getValue())) {
            return 2;
        }else if (StrUtil.equals(loanTime, BaseTypeInfoEnum.LoanTime.lt003.getValue())) {
            return 3;
        }
        return 5;
    }

    //用途
    public static Integer getYongtu(String yongtu) {
        if (StrUtil.equals(yongtu, BaseTypeInfoEnum.Yongtu.yt001.getValue())) {
            return 6;
        } else if (StrUtil.equals(yongtu, BaseTypeInfoEnum.Yongtu.yt002.getValue())) {
            return 1;
        }else if (StrUtil.equals(yongtu, BaseTypeInfoEnum.Yongtu.yt003.getValue())) {
            return 2;
        }else if (StrUtil.equals(yongtu, BaseTypeInfoEnum.Yongtu.yt004.getValue())) {
            return 3;
        }else if (StrUtil.equals(yongtu, BaseTypeInfoEnum.Yongtu.yt005.getValue())) {
            return 4;
        }
        return 8;
    }

    //信用卡
    public static Integer getXinYongKa(String xinyongka) {
        if (StrUtil.equals(xinyongka, BaseTypeInfoEnum.XinYongKa.xyk001.getValue())) {
            return 0;
        }else if (StrUtil.equals(xinyongka, BaseTypeInfoEnum.XinYongKa.xyk002.getValue())) {
            return 1;
        }else if (StrUtil.equals(xinyongka, BaseTypeInfoEnum.XinYongKa.xyk003.getValue())) {
            return 2;
        }else if (StrUtil.equals(xinyongka, BaseTypeInfoEnum.XinYongKa.xyk004.getValue())) {
            return 3;
        }
        return 4;
    }

    //花呗
    public static Integer getHuaBei(String huabei) {
        if (StrUtil.equals(huabei, BaseTypeInfoEnum.Huabei.hb001.getValue())) {
            return 0;
        }else if (StrUtil.equals(huabei, BaseTypeInfoEnum.Huabei.hb002.getValue())) {
            return 1;
        }if (StrUtil.equals(huabei, BaseTypeInfoEnum.Huabei.hb003.getValue())) {
            return 2;
        }if (StrUtil.equals(huabei, BaseTypeInfoEnum.Huabei.hb004.getValue())) {
            return 3;
        }
        return 4;
    }

    //白条
    public static Integer getBaiTiao(String baitiao) {
        if (StrUtil.equals(baitiao, BaseTypeInfoEnum.Baitiao.bt001.getValue())) {
            return 0;
        }else if (StrUtil.equals(baitiao, BaseTypeInfoEnum.Baitiao.bt002.getValue())) {
            return 1;
        }if (StrUtil.equals(baitiao, BaseTypeInfoEnum.Baitiao.bt003.getValue())) {
            return 2;
        }if (StrUtil.equals(baitiao, BaseTypeInfoEnum.Baitiao.bt004.getValue())) {
            return 3;
        }
        return 4;
    }

    //收入
    public static Integer getShouRu(String shouru) {
        if (StrUtil.equals(shouru, BaseTypeInfoEnum.Shouru.sr001.getValue())) {
            return 1;
        } else if (StrUtil.equals(shouru, BaseTypeInfoEnum.Shouru.sr002.getValue())) {
            return 2;
        } else if (StrUtil.equals(shouru, BaseTypeInfoEnum.Shouru.sr003.getValue())) {
            return 4;
        }
        return 5;
    }

    //学历
    public static Integer getXueLi(String education) {
        if (StrUtil.equals(education, BaseTypeInfoEnum.XueLi.xl001.getValue()) || StrUtil.equals(education, BaseTypeInfoEnum.XueLi.xl002.getValue())) {
            return 1;
        }else if (StrUtil.equals(education, BaseTypeInfoEnum.XueLi.xl003.getValue())) {
            return 2;
        }else if (StrUtil.equals(education, BaseTypeInfoEnum.XueLi.xl004.getValue())) {
            return 3;
        }
        return 4;
    }








}
